<% logged_as_admin = (user = session_user) && user.has_admin_privs? %>
<% logged_as_t_or_a = user && (user.has_author_privs? || user.has_teacher_privs? || user.has_admin_privs?) %>
<div class="main_menu" >
  <div class="menu_elements">
    <div class="search_ecase">
      <%= start_form_tag ({:controller => "search" } ,{:id =>"search_form", :method=> "post"}) %>
      <p><%= text_field_tag "search","",{:size => 34} %> <%= link_to_function "Search","$('search_form').submit()" %></p>
      <%= end_form_tag %>
    </div>
    <div class="menu" >
      <% if logged_as_admin || @selected_tab %>
        <ul>
        <% if @selected_tab %>
          <% if @selected_tab == :ecase %> 
            <li class="selected"><span>Case Study</span></li>
          <% else %> 
            <li><%=link_to "Case Study", {:controller=> "ecases", :action=> :show, :id => @ecase} %></li>
          <% end %>
          <% if @selected_tab == :resources %>
            <li class="selected"><span>Resources</span></li>
          <% else %>
            <li><%=link_to "Resources", {:controller => "resources", :id => @ecase} %></li>
          <% end %>
          <% if logged_as_t_or_a %>
            <% if @selected_tab == :teaching_notes %>
             <li class="selected"><span>Teaching Notes</span></li>
            <% else %>
             <li><%=link_to "Teaching Notes", {:controller=> "ecases", :action => :teaching_notes, :id => @ecase} %></li>
            <% end %>
          <% end %>     
        <% end %>
        <% if logged_as_admin %>
          <% if params[:controller] == "admin" %>
            <li class="selected" ><span>Administration</span></li>
          <% else %>
            <li><%=link_to "Administration", {:controller=> "admin"} %></li> 
          <% end %>
        <% end %>
        </ul>
      <% end %>
    </div>
    <div class="clear-float-right" ></div>
  </div>
</div>